/******************************************************************************
 *	@Author Raffaello Brondi
 *
 * 	@description Javascript framework to make XVR able to communicate with 
 *		Facebook.
 *
 *
 * Pare che questa sintassi 
 * 			(function(){}())
 * esegua direttamente la funzione al caricamento dello script.
 ******************************************************************************/
 
/******************************************************************************
 * Domain
 ******************************************************************************/
// var _fxb_domain = "https://159.213.137.77/facebook/fxb_api/";
 var _fxb_domain = "https://localhost/sonna/facebook/fxb_api/";

/******************************************************************************
 * Deafult id for container
 ******************************************************************************/ 
//var container_id = 'fb-root';

var _head;

/******************************************************************************
 * undefined type
  ******************************************************************************/
var undef = 'undefined';


/**********************************************************************
 * 	Loading all the needed script files
 **********************************************************************/
(function(){
	_head = getScriptTag().parentNode;
	if(typeof(_head) == undef)
		_head = createHeadTag();
		
	window.on_xvr_load_completed = function() {
		log('xvr load completed');
	};

	window.on_fb_load_completed = function() {
		log('fb load completed..Start loading XVR');
		loadXVR();
	};
	
	loadFB();
}());


/*******************************************************************************
 * @description
 * @param
 * @return
 ******************************************************************************/



/*******************************************************************************
 * @description Loads the XVR javascript library by appending a  new script tag
 *		in the head tag.
 ******************************************************************************/
function loadXVR(){
	var location = _fxb_domain + 'xvr/xvr_all.js';
	_head.appendChild(newScriptElement(location, true));
}


/*******************************************************************************
 * @description Loads the FB javascript library by appending a  new script tag
 *		in the head tag.
 ******************************************************************************/
function loadFB(){
	var location = _fxb_domain + 'fb/all.js';
	_head.appendChild(newScriptElement(location, true));
}


function importUser(){
	_xvr.sendData(_fb_user.getName());
}
